<!--
 * @Author: 迷洛洛ywc
 * @Date: 2024-05-30 15:07:05
 * @LastEditors: 迷洛洛ywc
 * @LastEditTime: 2024-06-01 23:13:22
 * @Description: file content
-->
<template>
  <div class="growthRecord">
    <div class="missionsMapBox">
      <!-- <missionsMap></missionsMap> -->
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
          <van-swipe-item
            ><img
              src="../assets/missionImg/Mask group2-1.jpg"
              alt=""
              style="object-fit:fill;"
          /></van-swipe-item>
          <van-swipe-item
            ><img
              src="../assets/missionImg/Mask group2-2.jpg"
              alt=""
              style="object-fit:fill;"
          /></van-swipe-item>
          <van-swipe-item
          ><img
            src="../assets/missionImg/Mask group2-3.jpg"
            alt=""
            style="object-fit:fill;"
        /></van-swipe-item>
        </van-swipe>
    </div>
    <!-- 农事任务信息 -->
    <div class="missionDetail">
      <div class="detailImg">
        <img :src="materialData[0]?.img" alt="" />
      </div>
      <div class="detailInfo">
        <div class="infoTop">
          <div class="infoTit">{{materialData?.type}}</div>
          <div class="infoBtn" @click="goDetail">详情 ></div>
        </div>
        <div class="infoBottom">
          <div class="infoItem" v-if="materialData[0]?.itemName">
            <div class="itemName">{{ materialData[0]?.itemName }}</div>
            <div class="itemNum">{{ materialData[0]?.itemNum }}</div>
          </div>
          <div class="infoItem" v-if="materialData[1]?.itemName">
            <div class="itemName">{{ materialData[1]?.itemName }}</div>
            <div class="itemNum">{{ materialData[1]?.itemNum }}</div>
          </div>
        </div>
      </div>
    </div>
    <!-- 农事日历波轮 -->
    <div class="missionDate">
      <div class="year">2024</div>
      <div class="missionList">
        <div
          class="missionBtn"
          v-for="(item, index) in missionsData"
          :key="index"
          @click="missionBtn(item)"
          :class="{'missionBtnActive':activeId === item.id}"
        >
          <div class="date">{{ item.time }}</div>
          <div class="missionType"><img v-if="activeId !== item.id" src="../assets/施肥_1.png" alt=""><img v-if="activeId === item.id" src="../assets/施肥 .png" alt=""> {{ item.type }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import missionsMap from '../components/missionMap.vue'
import Vue from 'vue'
import { Swipe, SwipeItem } from 'vant'

Vue.use(Swipe)
Vue.use(SwipeItem)
export default {
  name: 'ShuzhongtianH5GrowthRecord',
  components: {
    // missionsMap
  },

  data () {
    return {
      missionsData: [
        {
          id: 1,
          time: '04-20',
          type: '灌溉',
          material: [
            { itemName: '自动化灌溉', itemNum: '', img: require('@/assets/farming/0.jpg') }
          ]
        },
        {
          id: 2,
          time: '05-26',
          type: '灌溉',
          material: [
            { itemName: '自动化灌溉', itemNum: '', img: require('@/assets/farming/1.png') }
          ]
        },
        {
          id: 5,
          time: '06-03',
          type: '整田',
          material: [
            { itemName: '放水泡田', itemNum: '', img: require('@/assets/farming/5.jpg') },
            { itemName: '耙地', itemNum: '' }
          ]
        },
        {
          id: 3,
          time: '06-04',
          type: '施肥',
          material: [
            { itemName: '钱江绿有机肥料', itemNum: '1吨/亩', img: require('@/assets/farming/2.jpg') }
          ]
        },
        {
          id: 4,
          time: '06-05',
          type: '施肥',
          material: [
            { itemName: '种植家缓释掺混肥', itemNum: '60~80斤/亩', img: require('@/assets/farming/3.jpg') }
          ]
        },
        {
          id: 6,
          time: '11-26',
          type: '收割',
          material: [
            { itemName: '机器收割', itemNum: '', img: require('@/assets/farming/6.jpg') }
          ]
        }
      ],
      materialData: [],
      activeId: ''
    }
  },

  mounted () {
    this.missionBtn(this.missionsData[0])
  },

  methods: {
    missionBtn (item) {
      this.activeId = item.id
      this.materialData = { ...item.material, type: item.type }
    },
    goDetail () {
      this.$router.push({ name: 'missionDetail', query: { materialData: JSON.stringify(this.materialData) } })
    }
  }
}
</script>
<style lang="scss" scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  // background-color: #39a9ed;
  height: 457px;
  img {
    width: 100%;
    height: 457px;
  }
}
.growthRecord {
  width: 343px;
  min-height: 596px;
  background: #e7e7e7;
  border-radius: 0px 0px 0px 0px;
  padding: 12px 12px 12px;
  .missionsMapBox {
    position: relative;
    top: 0;
    left: 0;
    z-index: 1;
  }
  .missionDetail {
    width: 319px;
    height: 100px;
    background: #ffffff;
    border-radius: 4px 4px 4px 4px;
    margin-top: 10px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    .detailImg {
      width: 106px;
      height: 80px;
      background: #c5c5c5;
      border-radius: 4px 4px 4px 4px;
      img {
        width: 106px;
        height: 80px;
        border-radius: 0px 0px 0px 0px;
      }
    }
    .detailInfo {
      width: 185px;
      .infoTop {
        display: flex;
        justify-content: space-between;
        margin-bottom: 4px;
        .infoTit {
          width: 24px;
          height: 20px;
          font-family: PingFang SC, PingFang SC;
          font-weight: 500;
          font-size: 12px;
          color: #000000;
          line-height: 20px;
          text-align: justified;
        }
        .infoBtn {
          height: 18px;
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 10px;
          color: #666666;
          line-height: 18px;
          text-align: right;
        }
      }
      .infoBottom {
        .infoItem {
          width: 185px;
          height: 26px;
          background: #e8f8ef;
          border-radius: 2px 2px 2px 2px;
          margin-bottom: 4px;
          padding: 0 6px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 12px;
          color: #19b560;
        }
      }
    }
  }
  .missionDate {
    position: relative;
    .year {
      position: absolute;
      top: 0;
      left: 0;
      width: 32px;
      height: 72px;
      background: rgba(0, 0, 0, 0.8);
      border-radius: 0px 0px 0px 0px;
      writing-mode: vertical-rl;
      text-align: center;
      line-height: 36px;
      color: #ffffff;
      transform: rotate(-180deg); /* 逆时针旋转90度 */
      font-size: 16px;
      flex-wrap: 600;
    }
    .missionList {
      display: flex;
      flex-wrap: nowrap;
      padding-left: 36px;
      overflow-x: auto;
      width: 316px;
      height: 72px;
      .missionBtn {
        width: 72px;
        height: 72px;
        background: #ffffff;
        text-align: center;
        padding: 16px 0 12px;
        line-height: 1.5;
        margin-right: 4px;
        flex-shrink: 0;
        .missionType {
          font-size: 12px;
          img {
            box-sizing: border-box;
            width: 14px;
            height: 14px;
            margin-bottom: -2px;
          }
        }
      }
      .missionBtnActive {
        width: 72px;
        height: 72px;
        background: #2bc974;
        color: #ffffff;
        text-align: center;
        padding: 16px 0 12px;
        line-height: 1.5;
        margin-right: 4px;
        flex-shrink: 0;
      }
    }
  }
}
</style>
